From 7331683c01bed94ec8285d494658a0a2985659aa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 20 Jun 2023 12:34:01 -0400 Subject: [PATCH] a11y: Improve name computation We only want to settle on subtree content if it provides nonempty text. Otherwise, the tooltip should still win. This was clarified in the current Editor Draft of the accessible name computation spec. --- gtk/gtkatcontext.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index efbc572665..4d86184644 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -1321,7 +1321,7 @@ gtk_at_context_get_text_accumulate (GtkATContext *self, { if (GTK_IS_WIDGET (self->accessible)) { - gboolean has_child = FALSE; + GString *s = g_string_new (""); for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->accessible)); child != NULL; @@ -1330,13 +1330,17 @@ gtk_at_context_get_text_accumulate (GtkATContext *self, GtkAccessible *rel = GTK_ACCESSIBLE (child); GtkATContext *rel_context = gtk_accessible_get_at_context (rel); - gtk_at_context_get_text_accumulate (rel_context, nodes, res, property, relation, FALSE, TRUE); - - has_child = TRUE; + gtk_at_context_get_text_accumulate (rel_context, nodes, s, property, relation, FALSE, TRUE); } - if (has_child) - return; + if (s->len > 0) + { + g_string_append (res, s->str); + g_string_free (s, TRUE); + return; + } + + g_string_free (s, TRUE); } } -- 2.30.2